package com.kinptm.masterclock.bean;

import com.kinptm.masterclock.utils.TimeUtil;

/**
 * Created by pc on 13-11-7.
 */
public class IntervalTime {
    private long startTime;
    private long endTime;
    private SpeedTime speedTime;

    public IntervalTime() {
        this(0);
    }

    public IntervalTime(int startTime) {
        this.startTime = startTime;
        speedTime = new SpeedTime();
    }


    private void update(long spendTime) {
        TimeUtil.transform2Time(spendTime, speedTime);
    }

    public void reset() {
        startTime = 0;
        endTime = 0;
        speedTime.reset();
    }

    @Override
    public String toString() {
        return TimeUtil.formatTime(speedTime);
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getStartTime() {
        return startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
        update(endTime - startTime);
    }

    public long getSpendTime() {
        return endTime - startTime;
    }

    public SpeedTime getTime() {
        return speedTime;
    }
}
